//
// Created by 王乐 on 2022/2/9.
//

#ifndef LESTE_LEPARTICLESYSTEM_H
#define LESTE_LEPARTICLESYSTEM_H

#include "glm/glm.hpp"
#include <queue>

class LeGameObject;
class LeParticleGameObject;
struct LeParticle;

class LeParticleSystem
{
public:
    LeParticleSystem(LeGameObject* pGameObject);
    virtual ~LeParticleSystem();

public:
    // Emit particles in one frame,
    // Duration and EmitRate are controlled by gameobj behaviour.
    void emitParticles(unsigned int num, LeParticle& particledef,
                       glm::vec3 offset, glm::vec3 rangemin, glm::vec3 rangemax,
                       glm::vec2 rotrange,
                       glm::vec3 scalmin, glm::vec3 scalmax);

    void emitShadows(LeParticle& particledef);

public:
    LeParticleGameObject* getParticleGameObject(LeParticle &particledef, float r);
    void returnParticleGameObject(LeParticleGameObject* pgameobj);

    LeParticleGameObject* getShadowGameObject(LeParticle &particledef);
    void returnShadowGameObject(LeParticleGameObject* pgameobj);

private:
    LeGameObject* m_pGameObject;

    // TODO make a map <name, queue> for particle management
    std::queue<LeParticleGameObject*> m_qParticleGameObjects;
    std::queue<LeParticleGameObject*> m_qShadowGameObjects;

    int numShadows;
    // For Debug
public:
    int getPoolNum();
};


#endif //LESTE_LEPARTICLESYSTEM_H
